package com.jf.cloud.product.controller.multishop;

import com.jf.cloud.common.database.dto.PageDTO;
import com.jf.cloud.common.database.vo.PageVO;
import com.jf.cloud.common.product.dto.SpuDTO;
import com.jf.cloud.common.product.vo.SpuVO;
import com.jf.cloud.common.response.ServerResponseEntity;
import com.jf.cloud.common.security.AuthUserContext;
import com.jf.cloud.product.service.SpuService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("multishopSpuController")
@RequestMapping("/m/spu")
@Tag(name = "商品接口")
public class SpuController {

    @Autowired
    private SpuService spuService;

    @GetMapping("/pageSpuSku")
    @Operation(summary = "分页查询当前商家的spu及其sku信息" , description = "分页查询当前商家spu及其sku信息")
    public ServerResponseEntity<PageVO<SpuVO>> pageSpuSKu(PageDTO pageDTO, SpuDTO spuDTO) {
        Long shopId = AuthUserContext.get().getTenantId();
        spuDTO.setShopId(shopId);
        PageVO<SpuVO> page = spuService.pageSpuSku(pageDTO, spuDTO);
        return ServerResponseEntity.success(page);
    }
}
